<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8"%>
<%
String path = request.getContextPath()+"/";
%>
<!DOCTYPE html>
<html><head>
    <base href="<%=path%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>卡王贷申请进度查询</title>

<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<link rel="stylesheet" type="text/css" href="static/progress/css/aui.2.0.css">
<link rel="stylesheet" type="text/css" href="static/progress/css/style.css">
<script type="text/javascript" src="static/progress/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="static/progress/js/ec_gsc.js"></script>
<script language="javascript">
var gsc = new EC_GSC('FIN');
function getresult(){
	var mobile=$("#mobile").val();
	var mbcode=$("#mbcode").val();
	if(mobile==""){
		alert("请输入手机号");
		return false;
	}
	if(mbcode==""){
		alert("请输入验证码");
		return false;
	}
	var reg = /^(13[0-9]|14[5|7]|15[0-9]|17[0-9]|18[0-9])\d{8}$/;
    if(!reg.test(mobile)){
		alert("请输入正确的手机号");
		return false;
	}
	if(mbcode.length!=6){
		alert("请输入正确的验证码");
		return false;
	}
  gsc.verifyCode(mobile, mbcode, smsCodeCallback);
	// $("#addform").submit();
}
var wait=60;
function time() {
	if (wait == 0) {
		$("#yzm2").hide();
		$("#yzm1").show();
		wait = 60;
	} else {
		$("#yzm1").hide();
		$("#yzm2").show();
		$("#yzm2").text(wait+"s后重新获取");
		wait--;
		setTimeout(function() {
			time();
		},
		1000)
	}
}
function getmbcode(){
	var mobile = $('#mobile').val();
	if(mobile==""){
		alert("请输入手机号");
		return false;
	}
	var reg = /^1[3,4,5,6,7,8,9]\d{9}$/;
  if(!reg.test(mobile)){
		alert("请输入正确的手机号");
		return false;
	}
	var mobile = $('#mobile').val();
	$.ajax({
		type:"post",
		url:"check_code",
		data:{"mobile":$("#mobile").val(), "type":1},
		beforeSend: function(){
			$("#yzm1").hide();
			$("#yzm2").show();
		},
		error:function(){
			$("#yzm2").hide();
			$("#yzm1").show();
		},
		dataType: "json",
		success: function (data) {
			if(data.code == 200){
				time();
			}else{
				alert("请求失败，请重新进行提交");
				$("#yzm2").hide();
				$("#yzm1").show();
			}
		}
	});
}
function smsCodeCallback(ret) {
    console.log("Sms verify result = " + ret);
    if (ret === 0) {
        window.location.href = "https://lo139.com/webview/user/toResult?mobile="+$('#mobile').val();
        //window.location.href = "http://localhost:8080/webview/user/toResult?mobile="+$('#mobile').val();

    } else {
        alert("验证码输入错误");
    }
}
</script>
</head>
<body style="">
<div class="klqbg"><img src="static/progress/bg.jpg"></div>
<div class="klqcontent">
<div class="klqtxt">卡王贷申请进度查询</div>
<form id="addform" method="get" action="/user/toResult">
<div class="klqinput">
    <div class="aui-btn4 aui-btn-block4"><input type="number" id="mobile" name="mobile" placeholder="请输入手机号" style="text-align:left;padding-left:25px;" maxlength="11"></div>
</div>
<div class="klqinput-nbg">
    <div class="aui-col-xs-12" style="background-color: #Fff;"><input type="number" id="mbcode" name="mbcode" placeholder="请输入验证码" style="text-align:left;padding-left:25px;"></div>
    <div id="yzm1" class="aui-col-xs-5 yzmbtn1" onclick="getmbcode();">获取验证码</div>
    <div id="yzm2" class="aui-col-xs-5 yzmbtn2">获取验证码</div>
    <div class="aui-clearfix"></div>
</div>
<div class="klqbtn">
    <div class="aui-btn aui-btn-danger aui-btn-block" onclick="getresult();">查询</div>
</div>
</form>
</div>


</body></html>
